package org.apache.hadoop.hive.serde2.lazy;

import org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.LazyBinaryObjectInspector;
import org.apache.hadoop.io.BytesWritable;

public class CassandraLazyBinary extends LazyBinary {

    public CassandraLazyBinary(LazyBinaryObjectInspector oi) {
        super(oi);
    }

    public CassandraLazyBinary(LazyBinary other) {
        super(other);
        BytesWritable incoming = other.getWritableObject();
        byte[] bytes = new byte[incoming.getLength()];
        System.arraycopy(incoming.getBytes(), 0, bytes, 0, incoming.getLength());
        
        data = new BytesWritable(bytes);
    }

    @Override
    public void init(ByteArrayRef bytes, int start, int length) {
        byte[] recv = new byte[length];
        System.arraycopy(bytes.getData(), start, recv, 0, length);
        data.set(recv, 0, recv.length);
    }
}
